< previous page page_50 next page >

Page 50
Remember that the names you assign will be used in code, so avoid carpal tunnel syndrome by keeping them short!
To set the Name property for an object, select the object, view the Properties window (by clicking the Properties button; by selecting View, Properties Window; or by pressing the F4 key), and click the Name property. You can then type a new value. Figure 3.10 shows the Name property in the Properties window.
0050-01.jpg
Figure 3.10
The Name property is located at the
tip of the list on the Alphabetic page and
is the first property listed under the
Misc group on the Categorized page.
note.gif The Properties window displays in Visual Basic 6 by default, so you won't need to open it unless you have previously closed it.  square.gif

A First Look at Methods and Events
So far, this chapter has concentrated on properties, showing how they can control an object's appearance. In addition to properties, an object can have methods, which define tasks that it can perform. The tasks can be simple, such as moving the object to another location, or they can be more complex, such as updating information in a database.
Taking Action with Methods
A method is really just a program function that is built into the object. Using its embedded methods, the object knows how to perform the task; you don't have to provide any additional instructions. For example, forms have a PrintForm method that prints an image of the form on the current printer. The statement Form1.PrintForm prints an exact duplicate of Form1. Because the low-level details for the PrintForm method are encapsulated within the form object, a Visual Basic programmer does not have to be concerned with them.
As you may have guessed, methods, like properties, are referenced using dot notation. Visual Basic uses the Auto List Members feature described earlier to list an object's methods, properties, and events when you type the object's name followed by a period. Although different objects have different methods, many objects have the following methods in common:

 
< previous page page_50 next page >